import express from 'express'
const app = express();
import bodyParser from 'body-parser'
import cookieParser from'cookie-parser'
import configs from 'config'
const port = configs.get('post') || '3000'
const host = configs.get('host') || '0.0.0.0'
app.set('$config',configs)
import Iredis from './plugs/Iredis.js'
import router from './router'
//初始化redis
Iredis.getInstance();
app.use(cookieParser());
app.use(bodyParser.json({
  limit: '50mb'
})); // body-parser 解析json格式数据
app.use(bodyParser.urlencoded({
  limit: '50mb'
}))
app.engine('.html', require('ejs').__express);
app.set('view engine', 'html');
app.set('views', __dirname + '/views');
app.use(express.static(__dirname + '/public'));
app.use(router)
app.listen(port,host,()=>{
  console.log(`服务启动：http://${host}:${port}`);
})